package com.didispace.web;

import com.didispace.service.BlogProperties;
import com.didispace.service.BlogPropertiesConfig;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 *
 * @author 程序猿DD
 * @version 1.0.0
 * @blog http://blog.didispace.com
 *
 */
@RestController
public class HelloController {

    @Autowired
    private BlogProperties blog;

    @Autowired
    private BlogPropertiesConfig cf;

    /**
     * Environment自带的只能读取默认的配置文件里面的配置信息，
     * 自定义的配置文件在Environment是读取不了的
     */
    @Autowired
    private Environment env;

    @RequestMapping("/hello")
    public String index() {
        BlogProperties b = blog;
        BlogPropertiesConfig config = cf;
        String name = env.getProperty("com.didispace.blog.name");
        String name2 = env.getProperty("name"); // 返回null

        return "Hello World";
    }

}